<?php
include __DIR__ . '/../autoload.php';
    use lib\LocalRedis;
    use lib\Mysql;

    
    go(function () {
        $localRedis = new LocalRedis();
        $mysql = new Mysql();
        
        $time = time();
        
        for($i = 0; $i < 10; $i ++){
            
            $simIds = [];
            
            for ($z = 0; $z < 100; $z ++) {
                $sim = $localRedis->rpop('login-list');
                if($sim === null) {
                    break;
                }else{
                    array_push($simIds, '"' . $sim . '"');
                }
            }
            if(empty($simIds)) {
                break;
            }else{
                $ins = implode(',', $simIds);
                var_dump("update device set heart_time = {$time} where sim_iccid in ({$ins})");
                $mysql->query("update device set heart_time = {$time} where sim_iccid in ({$ins})");
            }
            
        }
        
        $localRedis->close();
        $mysql->close();
    });